import db from "../../db";

export default defineEventHandler(async (event) => {
  const { v_id } = getQuery(event);
  console.log("参数", v_id);
  if (!Number(v_id)) {
    return {
      code: -1,
      message: "参数错误：v_id",
    };
  }
  try {
    const [rows] = await db.query(`SELECT video_id,title,video_url,create_time,update_time FROM video_center where video_id=?`, [v_id]);
    const record = (rows as any[])[0];
    return {
      code: 1,
      message: "成功",
      data: record || null,
    };
  } catch (error) {
    console.error(error);
    return {
      code: 500,
      message: "服务器内部错误",
    };
  }
});
